package cn.wolfcode.qo;

import lombok.Data;

import java.util.List;

/**
 * @ClassName pageResult
 * @Description TODO
 * @Author wdx
 * @Date 2023/3/31 0:23
 */
@Data
public class pageResult<T> {
    private int currentPage;
    private int pageSize;
    
    private int totalCount;
    private List<T> data;

    private int prevPage;
    private int nextPage;
    private int totalPage;

    public pageResult(int currentPage, int pageSize, int totalCount, List<T> data) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
        this.data = data;
        this.totalPage = this.totalCount % this.pageSize == 0 ? this.totalCount / this.pageSize:
                this.totalCount / this.pageSize + 1 ;
        this.prevPage = this.currentPage - 1 >= 1 ? this.currentPage - 1 : 1;
        this.nextPage = this.currentPage + 1 <= this.totalPage ? this.currentPage + 1 : this.totalPage;
    }
}
